package com.gem.eolane.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gem.eolane.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface UserMapper extends BaseMapper<User> {

    //插入user
    @Insert("insert into user (user_name,password,phone_number,sex,company,mail) values(#{userName},#{password},#{phoneNumber},#{sex},#{company},#{mail})")
    void insertUser(String userName,String password,String phoneNumber,Integer sex,String company,String mail);

    //模糊查询总用户记录数
    @Select("select count(1) from user where user_name like '%${userName}%'")
    int userTotal(@Param("userName") String userName);

    //分页查询当前页的记录
    @Select("select * from user where user_name like '%${userName}%' limit #{currentPage},5")
    List<User> currentList(String userName ,int currentPage);

    //逻辑删除
    @Update("update user set del_ident = #{delIdent} where id = #{id}")
    void banUser(Integer id,Integer delIdent);

    //根据邮箱查询对象
    @Select("select * from user where phone_number = #{value}")
    User findUserByPhoneNumber(String phoneNumber);

    //根据手机号获取对象
    User queryUser(String phoneNumber);
    //修改用户信息
    void updateUser(User user);
    //用户密码修改
    void upadatePwd(User user);
}
